#include <cmath>
#include <functional>
#include <iostream>
using namespace std;

double square(double x) { return x * x; }

class Adder {
  const double d;

public:
  Adder(double delta) : d(delta) {}
  double operator()(double x) const { return x + d; }
};

int main() {
  double (*fpsin)(double) = sin;
  auto cube = [](double x) -> double { return x * x * x; };
  //  不支持&cos，可能因为有重载函数，不知道怎样选择double版本。
  function<double(double)> vf[]{fpsin, square, cube, Adder(1)};
  for (double d = 2; d < 5; ++d) {
    for (auto f : vf) {
      cout << d << " -> " << f(d) << endl;
    }
  }
}